package com.example.demo.controller;

import com.example.demo.service.AliPayService;
import com.example.demo.service.WxPayService;
import com.example.demo.vo.PayVO;
import com.example.demo.vo.ReqParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PayController {

    @Autowired
    private WxPayService wxPayService;
    @Autowired
    private AliPayService aliPayService;


    /**
     * 微信支付
     * @param reqParamVO
     */
    @RequestMapping(value = "/pay/wx", method = RequestMethod.POST)
    public void wxPay(@RequestBody ReqParam<PayVO> reqParamVO) {
        wxPayService.wxPay(reqParamVO.getData());
    }

    /**
     * 支付宝支付
     * @param reqParamVO
     */
    @RequestMapping(value = "/pay/ali", method = RequestMethod.POST)
    public void aliPay(@RequestBody ReqParam<PayVO> reqParamVO) {
        aliPayService.aliPay(reqParamVO.getData());
    }
}
